import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:silk_flutter/pages/decode_page.dart';
import 'package:silk_flutter/src/rust/frb_generated.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();
  await RustLib.init();
  await windowManager.setSize(const Size(1000, 600));
  await windowManager.setMinimumSize(const Size(1000, 600));
  await windowManager.setAlignment(Alignment.center);
  WindowOptions windowOptions = const WindowOptions(
    backgroundColor: Colors.transparent,
    titleBarStyle: TitleBarStyle.hidden,
    title: "Silk Decoder",
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      builder: FToastBuilder(),
      theme: ThemeData(fontFamily: "Leisurely"),
      home: DecodePage(),
    );
  }
}
